package org.jivesoftware.smack.filter;

import org.jivesoftware.smack.packet.Packet;

public class OrFilter
  implements PacketFilter
{
  private PacketFilter[] filters;
  private int size;

  public OrFilter()
  {
    this.size = 0;
    this.filters = new PacketFilter[3];
  }

  public OrFilter(PacketFilter paramPacketFilter1, PacketFilter paramPacketFilter2)
  {
    if ((paramPacketFilter1 == null) || (paramPacketFilter2 == null))
      throw new IllegalArgumentException("Parameters cannot be null.");
    this.size = 2;
    this.filters = new PacketFilter[2];
    this.filters[0] = paramPacketFilter1;
    this.filters[1] = paramPacketFilter2;
  }

  public boolean accept(Packet paramPacket)
  {
    int i = 0;
    while (true)
    {
      int j;
      if (i >= this.size)
        j = 0;
      while (true)
      {
        return j;
        if (!(this.filters[i].accept(paramPacket)))
          break;
        j = 1;
      }
      ++i;
    }
  }

  public void addFilter(PacketFilter paramPacketFilter)
  {
    PacketFilter[] arrayOfPacketFilter;
    int i;
    if (paramPacketFilter == null)
      throw new IllegalArgumentException("Parameter cannot be null.");
    if (this.size == this.filters.length)
    {
      arrayOfPacketFilter = new PacketFilter[2 + this.filters.length];
      i = 0;
    }
    while (true)
    {
      if (i >= this.filters.length)
      {
        this.filters = arrayOfPacketFilter;
        this.filters[this.size] = paramPacketFilter;
        this.size = (1 + this.size);
        return;
      }
      arrayOfPacketFilter[i] = this.filters[i];
      ++i;
    }
  }

  public String toString()
  {
    return this.filters.toString();
  }
}